<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<include file="Widget/head" />
	<link rel="stylesheet" href="__PUBLIC__/kindeditor-4.1.10/themes/default/default.css" />
	<script charset="utf-8" src="__PUBLIC__/kindeditor-4.1.10/kindeditor-min.js"></script>
	<script charset="utf-8" src="__PUBLIC__/kindeditor-4.1.10/lang/zh_CN.js"></script>
	<script type="text/javascript">
	var queryParams = {ajax:'y',cid:"{$cate}"};
	var myeditor;
	$(function(){
		var tb_search = document.getElementById('tb_search');
		queryParams.keyword = tb_search.keyword.value;
		$('#dg').datagrid({
			iconCls: 'icon-save',
			singleSelect: true,
			pagination:true,
			cache:false,
			method:'get',
			url: "{:U('lists')}" ,
			columns:[[
					{field:'mname',title:'商家账户',width:100,align:'center',halign:'center'},
					{field:'jdname',title:'刷手账户',width:100,align:'center',halign:'center'},
					{field:'title',title:'任务标题',width:300,halign:'center'},
					{field:'price',title:'任务总价',width:100,align:'center',halign:'center'},
					{field:'yongjin',title:'任务佣金',width:100,align:'center',halign:'center'},
					{field:'time_type',title:'申请日期',width:130,align:'right',halign:'center'},
					{field:'status',title:'发放状态',width:120,align:'center',halign:'center',
						formatter:function(value,row,index){
							if (value=='5') {
								return '已发';
							}else if(value == '4') {
								return '<a href="javascript:void(0)" class="my-btn btn-success" onclick="state('+row.id+')"><i class="fa fa-check"></i>同意放款</a>';
							}
						}
					},
			]],
			queryParams: queryParams,
			pageSize: {$_rows} ,
			pageNumber: {$_page},
			toolbar: '#tb',
			onDblClickRow: function() {
				editRow();
			}
		});
		var pager = $('#dg').datagrid('getPager');//分页对象
		pager.pagination({
			displayMsg:''
		});
	});
	//状态切换
	function state(id) {
		$('#dg').datagrid('loading');
		$.ajax({
			cache: false,
			type: "post",
			url: "{:U('state')}",
			data: {id:id},
			async: true, //同步请求, 其它操作必须等待请求完成才可以执行
			success: function(dd) {
				$('#dg').datagrid('reload');
				//$('#dg').datagrid('loaded');
			}
		});
	}
	function typechange(rec) {
		$('#tb_search').form('submit',{
			onSubmit:function(){
				//做数据处理
				goclear();
				$('#tb_search').form('load',{cate:rec.value});
				queryParams.cate = rec.value;
				$('#dg').datagrid('load',queryParams);
				return false;
			}
		});
	}
	
	//筛选查询
	function gosearch() {
		$('#tb_search').form('submit',{
			queryParams: {ajax:'y',cid:"{$cate}"},
			onSubmit:function(){
				//做数据处理
				queryParams.keyword = this.keyword.value;
				$('#dg').datagrid('load',queryParams);
				return false;
			}
		});
	}
	function goclear() {
		$('#tb_search').form('clear');
		queryParams = {ajax:'y',cid:"{$cate}"};
	}
	
	</script>
</head>

<body class="easyui-layout">
<table id="dg" title="" style="width:100%;height:100%" border="0"></table>

<div id="tb" class="datagrid-toolbar">
	<form id="tb_search" method="get">
	<table cellspacing="0" cellpadding="3">
	<tr>
		<td>任务名: <input name="keyword" class="easyui-textbox" style="width:100px" value="{$keyword}"></td>
		<td>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="gosearch()">搜索</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-undo" onclick="goclear()">清空</a>
		</td>
	</tr>
	</table>
	</form>
</div>
</body>
</html>